﻿#region using

using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

#endregion

namespace JupiterLibrary
{
    public class SkyDome
    {
        Effect effect;
        TextureCube texture;
        Model sphere;

        public SkyDome(string cubeTexture)
        {
            ContentManager Content = Jupiter.Content;

            effect = Content.Load<Effect>("Effects/SkySphere");
            texture = Content.Load<TextureCube>(cubeTexture);
            sphere = Content.Load<Model>("MeshFbx/SphereHighPoly");

            // Set the Skysphere Effect to each part of the Skysphere model
            foreach (ModelMesh mesh in sphere.Meshes)
            {
                foreach (ModelMeshPart part in mesh.MeshParts)
                {
                    part.Effect = effect;
                }
            }
        }

        public void Draw()
        {
            // Set the parameters of the effect
            effect.Parameters["ViewMatrix"].SetValue(Jupiter.Video.GlobalRender.Camera.View);
            effect.Parameters["ProjectionMatrix"].SetValue(Jupiter.Video.GlobalRender.Camera.Projection);
            effect.Parameters["SkyboxTexture"].SetValue(texture);

            sphere.Meshes[0].Draw();
        }
    }
}
